home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / NewsFlash - Issue 19 (1991-08)(UGA - NewsFlash UK)(Disk 1 of 2).zip / NewsFlash - Issue 19 (1991-08)(UGA - NewsFlash UK)(Disk 1 of 2).adf / sources / ColourSpread.S.pp / ColourSpread.S
Text File  |  1978-01-06  |  3KB  |  109 lines

  1. **********************************************************************
  2. *                                     *
  3. *                -Colour Spread Routine-                 *
  4. *                                     *
  5. *  Hi,with this routine you can calculate colour tints. Just put in  *
  6. * colour00 and in colour01 a colour. Put in -steps- how many colours *
  7. * you want.In -list- is standing, after running, the tints. The nice *
  8. * thing of this routine is,that for one whole "horizon", the routine *
  9. *    only calculates 3 numbers (counterINCvalue R,G,B) You simply    *
  10. *  increase the -Colour00- RGB nibbles with these numbers,and after  *
  11. *   -Steps- times -Colour01- is appearing.I know the routine isn`t   *
  12. *     very exactly, but in the game I wrote it for, time was more    *
  13. *  important. (In the game there is a horizon and while playing the  *
  14. *   sun goes down and the horizon become slightly blue)              *
  15. *                                     *
  16. * I hope you can use it. See Yha!          Erik Volkerink/MASSIVE *
  17. *                                     *
  18. ****************** (!!! LOOK OUT FOR OUR GAME !!!)  ******************
  19.  
  20.  
  21.  
  22. Colour00=        $0000    
  23. Colour01=        $0fff    
  24. Steps=            16    
  25.  
  26.  
  27.     bsr    calcincvalues    
  28.     bsr    storecolours
  29.     rts
  30.                 
  31.  
  32. Calcincvalues:
  33.     move.l    #colour00,d0    
  34.     move.l    #colour01,d1     
  35.     move.w    #steps,d2    
  36.     lea    counterINCval,a0;Pointer to RGB counter INC-table
  37.     lea    RGBcounters,a1    ;Pointer to RGB counters
  38.     jmp    CalcINCValue    ;Calculate counter INC values.
  39.  
  40. Storecolours:
  41.     lea    counterINCval,a0;Pointer to RGB Counter INC-table
  42.     lea    RGBcounters,a1    ;Pointer to RGB counters
  43.     lea    tints,a2    ;Destination pointer for colours
  44.     move.l    #steps-1,d4            
  45.     lus:            
  46.     bsr    nextcol        
  47.     move.w    d3,(a2)+    
  48.     dbra    d4,lus        
  49.     rts            
  50.  
  51. NextCol:movem.w    (a0),d0-d2    ;store CounterINCValue RGB to d0/d1/d2
  52.     add.w    d0,(a1)        ;Increase red counter
  53.     add.w    d1,2(a1)    ;Increase green counter
  54.     add.w    d2,4(a1)    ;Increase blue counter
  55.  
  56.     move.w    (a1),d3        ;
  57.     and.w    #$f00,d3    ;d3=red
  58.     move.w    2(a1),d1    ;
  59.     and.w    #$f00,d1    ;
  60.     lsr.w    #4,d1        ; 
  61.     add.w    d1,d3        ;d3=red+green
  62.     move.w    4(a1),d1    ;
  63.     and.w    #$f00,d1    ;
  64.     lsr.w    #8,d1        ;
  65.     add.w    d1,d3        ;d3 is complete word ($0RGB)
  66.     rts            ;
  67.  
  68. CalcINCValue:    
  69.     movem.w    d0-d1,-(a7)    
  70.  
  71.     ;Calculate Red INC Value
  72.     and.l    #$0f00,d0    ;Get red nibble of colour00
  73.     and.l    #$0f00,d1    ;Get red nibble of colour01
  74.     move.w    d0,(a1)        ;Start value of red*256
  75.     sub.l    d0,d1        ;d1=Space which have to be tide over
  76.     divs    d2,d1        ;(in d2(=number of tints) times)
  77.     move.w    d1,(a0)        ;Red INC Value*256  
  78.  
  79.     movem.w (a7),d0-d1    ;Get colours again 
  80.  
  81.     ;Calculate Green INC Value
  82.     and.l    #$00f0,d0    ;Get green nibble of colour00
  83.     and.l    #$00f0,d1    ;Get green nibble of colour01
  84.     lsl.l    #4,d0        ;*16 (Shift nibble one nibble to left)
  85.     lsl.l    #4,d1        ;*16 (  "     "    "     "    "   "  )
  86.     move.w    d0,2(a1)    ;Start value of green*256
  87.     sub.l    d0,d1        ;d1=Space which have to be tide over
  88.     divs    d2,d1        ;(in d2(=number of tints) times)
  89.     move.w    d1,2(a0)    ;Green INC Value*256
  90.  
  91.     movem.w (a7)+,d0-d1    ;Get colours again (a7 ptr back to 
  92.                 ;normal)
  93.  
  94.     ;Calculate Blue INC Value
  95.     and.l    #$000f,d0    ;Get blue nibble of colour00
  96.     and.l    #$000f,d1    ;Get blue nibble of colour01
  97.     lsl.l    #8,d0        ;*256 (shift nibble 2 nibbles to left)
  98.     lsl.l    #8,d1        ;*256 (  "     "    "   "      "   "
  99.     move.w    d0,4(a1)    ;Start value of blue*256
  100.     sub.l    d0,d1        ;d1=Space which have to be tide over
  101.     divs    d2,d1        ;(in d2(=number of tints) times)
  102.     move.w    d1,4(a0)    ;Blue INC Value*256
  103.     rts            
  104.  
  105. CounterINCVal:    dc.w    0,0,0   ;Counter INC values (R,G,B)
  106. RGBcounters:    dc.w    0,0,0   ;Counters (R,G,B)
  107.                     
  108. Tints:        blk.w    steps,0 
  109.